package com.analyse.stock.component;

import com.analyse.stock.model.StockKlineDailyModel;
import com.analyse.stock.vo.FactorParamVO;
import org.apache.commons.lang3.StringUtils;
import org.springframework.util.Assert;

import java.util.List;

public abstract class BizAbstract<R> {
    public String stockCode;

    public BizAbstract(String stockCode) {
        this.stockCode = stockCode;
    }

    /**
     * 参数校验
     * @return
     */
    public abstract String verify();

    /**
     * 获取 stockCode 对应的股票对应的 策略参数
     * 根据不同的因子（指标），和参数 去分析
     **/
    public abstract FactorParamVO getParam();

    /**
     * 获取 stockCode 对应的日内数据
     **/
    public abstract List<StockKlineDailyModel> getDailyKline();

    /**
     * 执行具体业务
     * @return
     */
    public abstract R handle();

    final public R exec(){
        //校验参数
        String error = this.verify();
        Assert.isTrue(StringUtils.isBlank(error),error);

        FactorParamVO paramVO = this.getParam();

        List<StockKlineDailyModel> dailys = this.getDailyKline();
        //处理具体业务
        R data = this.handle();

        return data;
    }
}
